﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YTCMS.Core;
using YTCMS.Domain.Entities;
using YTCMS.Services.Services;

namespace App.Controllers
{
    /// <summary>
    /// 纯玩攻略
    /// </summary>
    public class GuideController : Controller
    {
        private readonly IguideService _guide;
        public GuideController(IguideService guide)
        {
            this._guide = guide;
        }
        //
        // GET: /Guide/
        public ActionResult Index(int? pageIndex = 1, int? pageSize = 9)
        {
            int pcount = 0;
            var model = _guide.GetMany(s => true);
            model = _guide.PageList(model, pageIndex.Value - 1, pageSize.Value, out pcount);
            ViewBag.PageSize = pageSize.Value;
            ViewBag.TotalCount = pcount;
            ViewData["star"] = model.Where(s => s.IsPush == 1);
            return View(model);
        }
        public ActionResult Search(int? pageIndex = 1, int? pageSize = 9)
        {
            int pcount = 0;
            var model = _guide.GetMany(s => true);
            model = _guide.PageList(model, pageIndex.Value - 1, pageSize.Value, out pcount);
            ViewBag.PageSize = pageSize.Value;
            ViewBag.TotalCount = pcount;
            return PartialView("List", model);
        }

        public ActionResult Details(int id)
        {
            var model = _guide.Get(s => s.Id == id);
            var cid = model.CategoryId;
            ViewData["elseguide"] = _guide.GetMany(s => s.CategoryId == cid).Take(6);
            return View(model);
        }

	}
}